﻿using System ;
using Microsoft.Practices.Prism.Logging ;
using System.Collections.ObjectModel ;
using System.ComponentModel.Composition ;

namespace PrismExample
{

    [Export( typeof(StringCollectionLogger) )]
    [Export("StringCollectionLogger", typeof(ILoggerFacade))]
    public class StringCollectionLogger : ILoggerFacade
    {

        private ObservableCollection<string> _entries = null ;
        public ObservableCollection<string> Entries
        {
            get
            {

                if ( this._entries == null )
                {
                    this._entries = new ObservableCollection<string>( ) ;
                }
                return this._entries ;

            }
        }

        #region ILoggerFacade Members

        public void Log ( string message, Category category, Priority priority )
        {
            this.Entries.Add(String.Format( "{0} : {1} - {2}: {3}", DateTime.Now.ToString( ), priority.ToString( ), category.ToString( ), message ) ) ;
        }

        #endregion
    }
}